/*
 * DBAccess.h
 *
 *  Created on: 07-Nov-2014
 *      Author: ali
 */

#ifndef DBACCESS_H_
#define DBACCESS_H_
#include <sqlite3.h>
#include <iostream>
#include <stdexcept>
using namespace std;

class DBAccess
{
    friend class DBAccess_error;
public:
    DBAccess(const char* dbname);
    int
    Open(const char* dbname);
    int
    Close();
    int
    Exec(const char* sql);
    int ExecCommand(const char* sql);
    int ExecInsert(const char* sql);
    ~DBAccess();
private:
    sqlite3* m_db;
};

class DBAccess_error: public std::runtime_error
{
public:
    explicit DBAccess_error(char const* msg);
    explicit DBAccess_error(DBAccess& db);
};

#endif /* DBACCESS_H_ */
